package com.smedi.ismedi.constructionproject.core.application.query.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smedi.ismedi.constructionproject.core.application.command.ProjectApplyOneQuery;
import com.smedi.ismedi.constructionproject.core.application.convert.AppConverter;
import com.smedi.ismedi.constructionproject.core.application.query.ProjectApplyQueryService;
import com.smedi.ismedi.constructionproject.core.domain.aggregatemodel.ProjectApply;
import com.smedi.ismedi.constructionproject.core.domain.aggregatemodel.ProjectApplyListQuery;
import com.smedi.ismedi.constructionproject.core.domain.aggregatemodel.ProjectApplyPageQuery;
import com.smedi.ismedi.constructionproject.core.domain.aggregatemodel.ProjectApplyQuery;
import com.smedi.ismedi.constructionproject.core.domain.repository.ProjectApplyRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: xulinjun
 * @Date: 2021-6-24 15:33
 */
@Slf4j
@Service
@AllArgsConstructor
public class ProjectApplyQueryServiceImpl implements ProjectApplyQueryService {
    private final AppConverter appConverter;

    private final ProjectApplyRepository projectApplyRepository;


    @Override
    public ProjectApply getProjectApplyOne(ProjectApplyOneQuery projectApplyOneQuery) {

        ProjectApplyQuery projectApplyQuery = appConverter.projectApplyOneQueryToQuery(projectApplyOneQuery);

        return projectApplyRepository.getProjectApplyOne(projectApplyQuery);
    }

    @Override
    public List<ProjectApply> getProjectApplyList(ProjectApplyListQuery projectApplyListQuery) {
        ProjectApplyQuery projectApplyQuery = appConverter.projectApplyListQueryToQuery(projectApplyListQuery);
        return projectApplyRepository.getProjectApplyList(projectApplyQuery);
    }

    @Override
    public Page<ProjectApply> getProjectApplyPage(ProjectApplyPageQuery projectApplyPageQuery) {
        ProjectApplyQuery projectApplyQuery = appConverter.projectApplyPageQueryToQuery(projectApplyPageQuery);
        return projectApplyRepository.getProjectApplyPage(projectApplyQuery);
    }

    @Override
    public Boolean restoreProject(Long projectId) {
         return projectApplyRepository.restoreProject(projectId);
    }

}
